<!--各厂产能分析-->
<div style="height:15px;"></div>
<table class="layui-table gccnfx_table">
	<thead>
		<tr class="layui-bg-green">
			<th width="10%"></th>
			<?php foreach($factoryKV as $k=>$v){ if ($k==0) continue;?>
			<th width="<?php echo 90/count($factoryKV)?>%"><?php echo $v;?></th>
			<?php }?>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td>最近21日均量/压力</td>
			<?php foreach($factoryKV as $k=>$v) { if($k==0) continue;?>
			<td><span id="recently21_<?php echo $k;?>" class="<?php if($k==25 ||$k==26  ) echo 'gccnfx_table_td'; ?>" >0</span></td>
			<?php }?>
		</tr>
		<tr>
			<td>最近7日均量/压力</td>
			<?php foreach($factoryKV as $k=>$v) { if($k==0) continue;?>
			<td><span id="recently7_<?php echo $k;?>" class="<?php if($k==25 ||$k==26  ) echo 'gccnfx_table_td'; ?>">0</span></td>
			<?php }?>
		</tr>
		<tr>
			<td>在途产能</td>
			<?php foreach($factoryKV as $k=>$v) { if($k==0) continue;?>
			<td><span id="recentlyIng_<?php echo $k;?>" class="<?php if($k==25 ||$k==26  ) echo 'gccnfx_table_td'; ?>">0</span></td>
			<?php }?>
		</tr>
		<tr>
			<td>采购后在途产能/压力</td>
			<?php foreach($factoryKV as $k=>$v) { if($k==0) continue;?>
			<td><span id="afterPurchasingIng_<?php echo $k;?>" class="<?php if($k==25 ||$k==26  ) echo 'gccnfx_table_td'; ?>">0</span></td>
			<?php }?>
		</tr>
		<tr>
			<td>外发产能（上月）</td>
			<?php foreach($factoryKV as $k=>$v) { if($k==0) continue;?>
			<td><span id="lastmonth_<?php echo $k;?>" class="<?php if($k==25 ||$k==26  ) echo 'gccnfx_table_td'; ?>">0</span></td>
			<?php }?>
		</tr>
		<tr>
			<td>外发产能（本月）</td>
			<?php foreach($factoryKV as $k=>$v) { if($k==0) continue;?>
			<td><span id="thismonth_<?php echo $k;?>" class="<?php if($k==25 ||$k==26  ) echo 'gccnfx_table_td'; ?>">0</span></td>
			<?php }?>
		</tr>
	</tbody>
</table>

<script>
	var getGccnfx_data;
	var getGccnfx_flag=0;
layui.use(['jquery', 'layer'], function() {
	var $ = layui.jquery;
	var layer = layui.layer;
	
	//各厂产能分析
	window.getGccnfx = function() {
		$.ajax({
			type: "POST",
			url: "?c=dailyV2&m=index",
			data: "_ajax=1&fun=_getGccnfx"+"&from="+from,
			dataType: "json",
			success: function(res){
				getGccnfx_data=res;
				if(res.code == 1){
					var d = res.data;
					for(var i in d) {
						// 最近21日均量/压力
						$("#recently21_"+i).html(d[i]['recently21']['jianshu']+'件/'+d[i]['recently21']['jianshuPressure']+'<br>'+d[i]['recently21']['money']+'元/'+d[i]['recently21']['moneyPressure']);
	
						// 最近7日均量/压力
						$("#recently7_"+i).html(d[i]['recently7']['jianshu']+'件/'+d[i]['recently7']['jianshuPressure']+'<br>'+d[i]['recently7']['money']+'元/'+d[i]['recently7']['moneyPressure']);
	
						// 在途产能
						$("#recentlyIng_"+i).html(d[i]['recentlyIng']['jianshu']+'件<br>'+d[i]['recentlyIng']['money']+'元');
	
						// 采购后在途产能/压力
						afterPurchasingIng = d[i]['afterPurchasingIng']['jianshu']+'件/'+d[i]['afterPurchasingIng']['jianshuPressure']+'<br>'+d[i]['afterPurchasingIng']['money']+'元/'+d[i]['afterPurchasingIng']['moneyPressure'];
						$("#afterPurchasingIng_"+i).html(afterPurchasingIng);
	
						// // 最近4日出货
						// recently4 = d[i]['recently1']['jianshu']+'件/'+d[i]['recently2']['jianshu']+'件/'+d[i]['recently3']['jianshu']+'件/'+d[i]['recently4']['jianshu']+'件<br>';
						// recently4 += d[i]['recently1']['money']+'件/'+d[i]['recently2']['money']+'元/'+d[i]['recently3']['money']+'元/'+d[i]['recently4']['money']+'元';
						// $("#recently4_"+i).html(recently4);
						//
						// // 最近4日下单
						// recently4orders = d[i]['recently1']['orders']+'件/'+d[i]['recently2']['orders']+'件/'+d[i]['recently3']['orders']+'件/'+d[i]['recently4']['orders']+'件';
						// $("#recently4orders_"+i).html(recently4orders);
						//
						// // 最近4日/7日下单均量
						// recentlyAvg = d[i]['recently4avg']['orders']+'件/'+d[i]['recently7avg']['orders']+'件<br>'+d[i]['recently4avg']['money']+'元/'+d[i]['recently7avg']['money']+'元';
						// $("#recentlyAvg_"+i).html(recentlyAvg);
	
						// 外发产能（上月）
						$("#lastmonth_"+i).html(d[i]['lastMonthOutgo']['jianshu']+'件/'+d[i]['lastMonthOutgo']['money']+'元<br>占比：'+d[i]['lastMonthOutgoRate']['jianshu']+'/'+d[i]['lastMonthOutgoRate']['money']);
						// 外发产能（本月）
						$("#thismonth_"+i).html(d[i]['thisMonthOutgo']['jianshu']+'件/'+d[i]['thisMonthOutgo']['money']+'元<br>占比：'+d[i]['thisMonthOutgoRate']['jianshu']+'/'+d[i]['thisMonthOutgoRate']['money']);

						if((i==25 || i==26 )&& d[i]['recently21']['jianshuPressure']==0 && getGccnfx_flag==0){
							getGccnfx_flag=1;
							$('.layui-bg-green').find('.menu_action').trigger('click');
						}
					}
				}else layer.msg(res.msg, {icon: 2,anim: 6});
			}
		});
	};
	getGccnfx(); 		// 各厂产能分析
});
</script>